import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ImgVO, ImgForm, ImgQuery } from '@/api/module/product/img/types';

/**
 * 查询商品图片列表
 * @param query
 * @returns {*}
 */

export const listImg = (query?: ImgQuery): AxiosPromise<ImgVO[]> => {
  return request({
    url: '/module/img/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询商品图片详细
 * @param id
 */
export const getImg = (id: string | number): AxiosPromise<ImgVO> => {
  return request({
    url: '/module/img/' + id,
    method: 'get'
  });
};

/**
 * 新增商品图片
 * @param data
 */
export const addImg = (data: ImgForm) => {
  return request({
    url: '/module/img',
    method: 'post',
    data: data
  });
};

/**
 * 修改商品图片
 * @param data
 */
export const updateImg = (data: ImgForm) => {
  return request({
    url: '/module/img',
    method: 'put',
    data: data
  });
};

/**
 * 删除商品图片
 * @param id
 */
export const delImg = (id: string | number | Array<string | number>) => {
  return request({
    url: '/module/img/' + id,
    method: 'delete'
  });
};
